#include<iostream>
using namespace std;
typedef int ElementType;
#define SetType_MaxSize 10001

typedef struct {
	ElementType Data;
	int Parents;
}SetType;

int SetType_Find(SetType S[], ElementType x)
{
	int i;
	for ( i = 0; i < SetType_MaxSize && S[i].Data != x;i++)
	{
		if (i >= SetType_MaxSize)
		{
			return -1;
		}
		for (; S[i].Parents >= 0; i = S[i].Parents);
		return i;
	}
}

void Union(SetType S[], ElementType x1, ElementType x2)
{
	int Root1, Root2;
	Root1 = SetType_Find(S, x1);
	Root2 = SetType_Find(S, x2);
	if (Root1 != Root2)
	{
		S[Root2].Parents = Root1;
	}
}